//package cn.changeforyou.analyzer.netDemo;
//
//import cn.changeforyou.utils.io.read.ReadUtils;
//import java.io.FileInputStream;
//import java.io.FileNotFoundException;
//import java.io.InputStream;
//import java.io.InputStreamReader;
//import java.io.UnsupportedEncodingException;
//import org.eclipse.jdt.core.dom.AST;
//import org.eclipse.jdt.core.dom.ASTParser;
//import org.eclipse.jdt.core.dom.CompilationUnit;
//import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
//import org.eclipse.jface.text.BadLocationException;
//import org.eclipse.text.edits.TextEdit;
//import org.junit.jupiter.api.Test;
//
///**
// * @author zhyu
// * @date 2021/2/2 16:42
// */
//public class EclipseAstRewriteDemo {
//
//    @Test
//    public void test(){
//        try {
//            String path = "D:\\code\\analyzer\\analyzer\\src\\test\\resources\\javaFiles\\HelloWorld.java";
//            String content = ReadUtils.readReaderToString(new InputStreamReader(new FileInputStream(path), "UTF-8"));
//            org.eclipse.jface.text.Document document = new org.eclipse.jface.text.Document(content);
//            ASTParser parser = ASTParser.newParser(AST.JLS8);
//            parser.setSource(document.get().toCharArray());
//            parser.setKind(ASTParser.K_COMPILATION_UNIT);
//
//            final CompilationUnit cu = (CompilationUnit) parser.createAST(null);
//            ASTRewrite rewriter = ASTRewrite.create(cu.getAST());
//
//            cu.recordModifications();
//
//            TextEdit edits = rewriter.rewriteAST(document,null);
//
//
//            edits.apply(document);
//
//        } catch (UnsupportedEncodingException e) {
//            e.printStackTrace();
//        } catch (BadLocationException e) {
//            e.printStackTrace();
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        }
//
////        FileUtils.write(javaSRC, document.get());
//    }
//}
